package com.tpod.taxi.view.adapter;

import java.util.ArrayList;

import com.tpod.taxi.R;
import com.tpod.taxi.entity.City;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ListItemPopUpAdapter extends BaseAdapter{
	Context mContext;
	ArrayList<City> datas = new ArrayList<City>();
	private LayoutInflater mInflater;
	 
	
	public ListItemPopUpAdapter(Context context) {
		super();
		this.mContext = context;
		mInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return datas.size();
	}

	@Override
	public City getItem(int arg0) {
		// TODO Auto-generated method stub
		return datas.get(arg0);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	public void add(City city)
	{
		datas.add(city);
		notifyDataSetChanged();
	}
	public int getIdCity(int pos)
	{
		return datas.get(pos).getId();
		
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View v = convertView;
		v = mInflater.inflate(R.layout.action_item_vertical, null);
		ImageView img = (ImageView) v.findViewById(R.id.action_item_vertical_iv_icon);
		TextView text = (TextView) v.findViewById(R.id.action_item_vertical_tv_title);
		text.setText(datas.get(position).getName());
		return v;
	}

}
